package demo;

import entity.Student;

import java.util.function.Consumer;

/**
 * consumer demo
 *
 * @author dingwen
 * 2021.05.19 10:47
 */
public class ConsumerDemo {
    public static void main(String[] args) {
        Consumer<Student> consumer1 = (student -> print(student.getName()));
        Consumer<Student> consumer2 = (student -> print(student.getGender()));

        Student student = new Student();
        student.setGender("男");
        student.setName("dingwen");

//        consumer2.accept(student);
        consumer1.andThen(consumer2).accept(student);
    }


    /**
     * 打印
     *
     * @param str str
     */
    public static void print(String str) {
        System.out.println(str);
    }
}
